#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my $config      = read_conf_file();
my $path        = $config->{PATH};
my $indexes_dir = $config->{INDEXES_DIR};
my $genome      = $config->{GENOME};
my $out_file    = $config->{OUT_FILE};
my $gtf_dir     = $config->{GTF_DIR};
my $gtf_file    = $config->{GTF_FILE};
# gffread -g castor_bowtie_index.ebwt.fa 
# -W -w cuffcompare_combined_v_cator_exons.combined.fna cuffcompare_combined_v_cator_exons.combined.gtf

warn Dumper $config;

my $cmd  = qq(bsub -Is -n 4 -R "span[ptile=4] rusage[mem=5000]" )
         . qq(cufflinks-1.3.0 gffread -g $indexes_dir/$genome )
         . qq(-W -w results/$out_file )
         . qq( $gtf_dir/$gtf_file );

print "$cmd\n";
#system();


sub read_conf_file {
  my $user_preferences;
  open CONFIG, "/usr/users/ga002/corpasm/workarea/ricinus/conf/gffread.conf" or die $!;
    while (<CONFIG>) {
    chomp;                  # no newline
    s/#.*//;                # no comments
    s/^\s+//;               # no leading white
    s/\s+$//;               # no trailing white
    next unless length;     # anything left?
    my ($var, $value) = split(/\s*=\s*/, $_, 2);
    
    $user_preferences->{$var} = $value;
  } 
  return $user_preferences;
}
